import 'package:flutter/material.dart';

class RadioOption<T> extends StatelessWidget {
  final T value;
  final T? groupValue;
  final String text;
  final ValueChanged<T?> onChanged;
  final TextStyle? textStyle;

  const RadioOption({
    Key? key,
    required this.value,
    required this.groupValue,
    required this.text,
    required this.onChanged,
    this.textStyle,
  }) : super(key: key);

  Widget _buildText() {
    return Text(
      text,
      style: textStyle ?? const TextStyle(fontSize: 15),
    );
  }

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () => onChanged(value),
      child: Wrap(
        crossAxisAlignment: WrapCrossAlignment.center,
        children: [
          SizedBox(
            width: 22,
            height: 18,
            child: Radio(
              value: value,
              groupValue: groupValue,
              onChanged: onChanged,
            ),
          ),
          _buildText(),
        ],
      ),
    );
  }
}
